package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BizPondInfo;
import com.ruoyi.system.service.IBizPondInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 养殖池管理Controller
 * 
 * @author luoshuai
 * @date 2023-06-20
 */
@RestController
@RequestMapping("/system/info")
public class BizPondInfoController extends BaseController
{
    @Autowired
    private IBizPondInfoService bizPondInfoService;

    /**
     * 查询养殖池管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizPondInfo bizPondInfo)
    {
        startPage();
        List<BizPondInfo> list = bizPondInfoService.selectBizPondInfoList(bizPondInfo);
        return getDataTable(list);
    }

    /**
     * 导出养殖池管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "养殖池管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizPondInfo bizPondInfo)
    {
        List<BizPondInfo> list = bizPondInfoService.selectBizPondInfoList(bizPondInfo);
        ExcelUtil<BizPondInfo> util = new ExcelUtil<BizPondInfo>(BizPondInfo.class);
        util.exportExcel(response, list, "养殖池管理数据");
    }

    /**
     * 获取养殖池管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{pondId}")
    public AjaxResult getInfo(@PathVariable("pondId") Long pondId)
    {
        return success(bizPondInfoService.selectBizPondInfoByPondId(pondId));
    }

    /**
     * 新增养殖池管理
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "养殖池管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizPondInfo bizPondInfo)
    {
        return toAjax(bizPondInfoService.insertBizPondInfo(bizPondInfo));
    }

    /**
     * 修改养殖池管理
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "养殖池管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizPondInfo bizPondInfo)
    {
        return toAjax(bizPondInfoService.updateBizPondInfo(bizPondInfo));
    }

    /**
     * 删除养殖池管理
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "养殖池管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pondIds}")
    public AjaxResult remove(@PathVariable Long[] pondIds)
    {
        return toAjax(bizPondInfoService.deleteBizPondInfoByPondIds(pondIds));
    }
}
